//
// Created by yunnan xu on 2020/11/21.
//

#ifndef ANDROIDGRAPHICSDEMOS_CAMERA_H
#define ANDROIDGRAPHICSDEMOS_CAMERA_H

#include "glm.hpp"

class Camera
{
public:

    Camera(float z_near, float z_far, float aspect_ratio, float fov);

    void AddPositionVec(glm::vec3 add_vec);
    void SetPosition(glm::vec3 pos_vec);
    void SetForward(glm::vec3 for_vec);

    glm::mat4x4 GetCameraTransform() const;
    const glm::mat4x4 & GetViewMatrix() const;
    const glm::mat4x4 & GetProjMatrix() const;

    glm::vec3 GetPosition () const;
    glm::vec3 GetForward () const;
    glm::vec3 GetUp () const;
    glm::vec3 GetRight() const;

    void SetOnMobileInput();

private:

    glm::mat4x4 viewMatrix;
    glm::mat4x4 projMatrix;

    glm::vec3 position;
    glm::vec3 forward;
    glm::vec3 up;
    glm::vec3 right;

    // z平面 near far 距离
    float zNear;
    float zFar;

    // 宽高比
    float aspectRatio;

    // y轴的FOV
    float fov;

    void UpdateMatrix();

    float lastCenterX;
    float lastCenterY;
};


#endif //ANDROIDGRAPHICSDEMOS_CAMERA_H
